package com.ruoyi.wcf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wcf.domain.WcfClassManage;
import com.ruoyi.wcf.service.IWcfClassManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分类管理Controller
 * 
 * @author LCL
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/wcf/WcfClassManage")
public class WcfClassManageController extends BaseController
{
    @Autowired
    private IWcfClassManageService wcfClassManageService;

    /**
     * 查询分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfClassManage:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcfClassManage wcfClassManage)
    {
        startPage();
        List<WcfClassManage> list = wcfClassManageService.selectWcfClassManageList(wcfClassManage);
        return getDataTable(list);
    }

    /**
     * 导出分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfClassManage:export')")
    @Log(title = "分类管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcfClassManage wcfClassManage)
    {
        List<WcfClassManage> list = wcfClassManageService.selectWcfClassManageList(wcfClassManage);
        ExcelUtil<WcfClassManage> util = new ExcelUtil<WcfClassManage>(WcfClassManage.class);
        return util.exportExcel(list, "分类管理数据");
    }

    /**
     * 获取分类管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfClassManage:query')")
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") Long classId)
    {
        return AjaxResult.success(wcfClassManageService.selectWcfClassManageByClassId(classId));
    }

    /**
     * 新增分类管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfClassManage:add')")
    @Log(title = "分类管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcfClassManage wcfClassManage)
    {
        return toAjax(wcfClassManageService.insertWcfClassManage(wcfClassManage));
    }

    /**
     * 修改分类管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfClassManage:edit')")
    @Log(title = "分类管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcfClassManage wcfClassManage)
    {
        return toAjax(wcfClassManageService.updateWcfClassManage(wcfClassManage));
    }

    /**
     * 删除分类管理
     */
    @PreAuthorize("@ss.hasPermi('wcf:WcfClassManage:remove')")
    @Log(title = "分类管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable Long[] classIds)
    {
        return toAjax(wcfClassManageService.deleteWcfClassManageByClassIds(classIds));
    }
}
